<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/vue.js"></script>
</head>

<body>

    <div id="root">
        <h2>今天天气很{{info}}</h2>
        <button @click="changeWeather()">切换天气</button><br>

    </div>
</body>
<script>
    Vue.config.productionTip = false;
    const vm = new Vue({
        el: "#root",
        data: {
            isHot: true
        },
        methods: {
            changeWeather() {
                this.isHot = !this.isHot;
            }
        },
        computed: {
            info: {
                get() {
                    return this.isHot ? "炎热" : "凉爽";
                }
            }
        },
        // watch:{
        //     //简写：
        //     isHot(newValue,oldValue){
        //             console.log("isHot被修改",newValue,oldValue);
        //         }
        //     }

    })
    vm.$watch("isHot", function (newValue, oldValue) {
        console.log("isHot被修改", newValue, oldValue);
    });
</script>

</html>